package cn.mju.tankfighterbackend.util

import cn.mju.tankfighterbackend.dto.game.PlayerOptionDto
import cn.mju.tankfighterbackend.entity.CustomerUser
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.registerKotlinModule

object JsonUtil {

     val objectMapper = jacksonObjectMapper().registerKotlinModule()

    fun <T> convertToString(obj: T): String {
        return objectMapper.writeValueAsString(obj)
    }

    inline fun < reified T> convertToObject(jsonString: String): T {

        return objectMapper.readValue(jsonString)
    }

}